class Loader {
  doload(fileName, callback) {
    const url = fileName
    const opt = {
      method: 'GET'
    }
    fetchJson(url, opt).then(data => {
      console.log(data)
      const imgWrap = []
      var loadSucNumber = 0
      function preloadImg(arr) {
        for (let i = 0; i < arr.length; i++) {
          let imageElement = new Image()
          imageElement.onload = function() {
            loadSucNumber++
            console.log('suc')
            if (loadSucNumber >= data.fileNameList.length) {
              console.log('加载完毕!')
              callback(imgWrap)
            }
          }
          imageElement.src = arr[i]
          imgWrap.push(imageElement)
        }
      }
      preloadImg(data.fileNameList)
    })
  }
}

export default Loader